/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import com.icinfo.cloud.provider.common.constant.Constant;

import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseReasonMainRecordQueryDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseReasonMainRecordSaveDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICaseReasonMainRecordService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseReasonMainRecordVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述: 案件案由记录表 case_reason_main_record 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年02月22日
 */
@RestController
@RefreshScope
@RequestMapping("/punish/ucase/caseParties")
@Slf4j
public class CaseReasonMainRecordController extends BaseController {
    @Resource
    private ICaseReasonMainRecordService caseReasonMainRecordService;

    /**
     * 【V1.0.0】描述：保存案件案由记录
     *
     * @param saveDto {@link CaseReasonMainRecordSaveDto}
     * @return {@link Result <String>} 保存结果
     * @author xiangyuyu
     * @date 2022-02-28 10:47
     */
    @PostMapping("/saveCaseReasonRecord")
    @ApiOperation(value = "【V1.0.0】描述：保存案件案由记录", httpMethod = "POST")
    public Result<String> saveCaseReasonRecord(@RequestBody @Validated CaseReasonMainRecordSaveDto saveDto) {
        return caseReasonMainRecordService.saveCaseReasonRecord(saveDto);
    }

    /**
     * 【V1.0.0】描述：获取案件案由列表
     *
     * @param queryDto {@link CaseReasonMainRecordQueryDto}
     * @return {@link Result<List< CaseReasonMainRecordVo >} 案件案由列表
     * @author xiangyuyu
     * @date 2022-02-28 10:47
     */
    @PostMapping("/getCaseReasonRecordList")
    @ApiOperation(value = "【V1.0.0】描述：获取案件案由列表", httpMethod = "POST")
    public Result<List<CaseReasonMainRecordVo>> getCaseReasonRecordList(@RequestBody @Validated CaseReasonMainRecordQueryDto queryDto) {
        List<CaseReasonMainRecordVo> list = caseReasonMainRecordService.getCaseReasonRecordList(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, list);
    }

    /**
     * 【V1.0.0】描述：根据唯一标识查询案件案由记录
     *
     * @param id 唯一标识
     * @return {@link Result< CaseReasonMainRecordVo >} 案件案由记录
     * @author xiangyuyu
     * @date 2022-02-28 10:47
     */
    @PostMapping("/getCaseReasonRecord")
    @ApiOperation(value = "【V1.0.0】描述：根据唯一标识查询案件案由记录", httpMethod = "POST")
    public Result<CaseReasonMainRecordVo> getCaseReasonRecord(@RequestParam String id) {
        CaseReasonMainRecordVo vo = caseReasonMainRecordService.getCaseReasonRecord(id);
        return Result.success(Constant.STRING_GET_SUCCESS, vo);
    }

    /**
     * 描述：根据案件id获取案件案由详情数据【V2.0.0前仅适用单案由】
     *
     * @param caseId 案件id
     * @return {@link Result<    CaseReasonMainRecordVo >} 案件案由详情数据
     * @author xiangyuyu
     * @date 2022-02-28 11:17
     */
    //@PostMapping("/getCaseReasonRecordByCaseId")
    @ApiOperation(value = "【V1.0.0】描述：根据案件id获取案件案由详情数据【V2.0.0前仅适用单案由】", httpMethod = "POST")
    @Deprecated
    public Result<CaseReasonMainRecordVo> getCaseReasonRecordByCaseId(@RequestParam String caseId) {
        CaseReasonMainRecordVo vo = caseReasonMainRecordService.getCaseReasonRecordByCaseId(caseId);
        return Result.success(Constant.STRING_GET_SUCCESS, vo);
    }

    /**
     * 描述：根据案件id获取案件案由详情数据-适配多案由
     *
     * @param caseId 案件id
     * @return {@link Result<List<CaseReasonMainRecordVo>>} 案件案由详情数据
     * @author xiangyuyu
     * @date 2022-05-23 09:20
     */
    @PostMapping("/getCaseReasonRecordListByCaseId")
    @ApiOperation(value = "【V1.0.0】描述：根据案件id获取案件案由详情数据-适配多案由", httpMethod = "POST")
    public Result<List<CaseReasonMainRecordVo>> getCaseReasonRecordListByCaseId(@RequestParam String caseId) {
        List<CaseReasonMainRecordVo> list = caseReasonMainRecordService.getCaseReasonRecordListByCaseId(caseId);
        return Result.success(Constant.STRING_GET_SUCCESS, list);
    }

}